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

class B:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

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

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

class F:
    def __init__(self, txt: str):
        self.o: C = None
        self.s: B = None
        self.x: C = None
        self.txt = txt

j = A("j")
i = B("i")
c = C("c")
h = D("h")
f = E("f")
n = F("n")
d = C("d")

j.z = d
i.v = j
c.z = j
c.w = j
c.q = f
c.x = d
h.q = f
h.o = n
h.r = c
f.p = d
n.o = c
n.x = c
n.s = i
d.z = j
d.w = j
d.q = f
d.x = c
assert c.x.z.z.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

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

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

class F:
    def __init__(self, txt: str):
        self.o: C = None
        self.s: B = None
        self.x: C = None
        self.txt = txt

j = A("j")
i = B("i")
c = C("c")
h = D("h")
f = E("f")
n = F("n")
d = C("d")

j.z = d
i.v = j
c.z = j
c.w = j
c.q = f
c.x = d
h.q = f
h.o = n
h.r = c
f.p = d
n.o = c
n.x = c
n.s = i
d.z = j
d.w = j
d.q = f
d.x = c
assert c.x.z.z.x.q.txt == "f"