class A:
    def __init__(self, txt: str):
        self.x: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: D = None
        self.t: C = None
        self.w: E = None
        self.q: C = None
        self.u: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.r: A = None
        self.w: B = None
        self.o: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.y: C = None
        self.v: B = None
        self.txt = txt

a = A("a")
g = B("g")
b = C("b")
f = D("f")
n = E("n")
j = F("j")
m = B("m")
c = C("c")

a.x = j
g.o = f
g.t = c
g.w = n
g.q = b
g.u = m
b.p = f
f.r = a
f.w = m
f.o = c
n.w = c
j.y = c
j.v = g
m.o = f
m.t = c
m.w = n
m.q = b
m.u = g
c.p = f
assert c.p.o.p.w.t.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: D = None
        self.t: C = None
        self.w: E = None
        self.q: C = None
        self.u: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.r: A = None
        self.w: B = None
        self.o: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.y: C = None
        self.v: B = None
        self.txt = txt

a = A("a")
g = B("g")
b = C("b")
f = D("f")
n = E("n")
j = F("j")
m = B("m")
c = C("c")

a.x = j
g.o = f
g.t = c
g.w = n
g.q = b
g.u = m
b.p = f
f.r = a
f.w = m
f.o = c
n.w = c
j.y = c
j.v = g
m.o = f
m.t = c
m.w = n
m.q = b
m.u = g
c.p = f
assert c.p.o.p.w.t.p.w.txt == "m"