class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.u: B = None
        self.q: A = None
        self.x: F = None
        self.r: C = None
        self.w: F = None
        self.z: D = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.w: E = None
        self.p: C = None
        self.x: A = None
        self.z: D = None
        self.o: D = None
        self.txt = txt

d = A("d")
k = B("k")
m = C("m")
j = D("j")
f = E("f")
i = F("i")
g = B("g")

d.q = m
k.r = m
k.v = m
k.y = g
k.p = f
m.q = d
m.o = j
j.x = m
f.u = g
f.q = d
f.x = i
f.w = i
f.r = m
f.z = j
i.w = f
i.p = m
i.x = d
i.z = j
i.o = j
g.r = m
g.v = m
g.y = k
g.p = f
assert j.x.o.x.o.x.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.u: B = None
        self.q: A = None
        self.x: F = None
        self.r: C = None
        self.w: F = None
        self.z: D = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.w: E = None
        self.p: C = None
        self.x: A = None
        self.z: D = None
        self.o: D = None
        self.txt = txt

d = A("d")
k = B("k")
m = C("m")
j = D("j")
f = E("f")
i = F("i")
g = B("g")

d.q = m
k.r = m
k.v = m
k.y = g
k.p = f
m.q = d
m.o = j
j.x = m
f.u = g
f.q = d
f.x = i
f.w = i
f.r = m
f.z = j
i.w = f
i.p = m
i.x = d
i.z = j
i.o = j
g.r = m
g.v = m
g.y = k
g.p = f
assert j.x.o.x.o.x.o.txt == "j"