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

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

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

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

class E:
    def __init__(self, txt: str):
        self.t: B = None
        self.z: C = None
        self.v: A = None
        self.p: B = None
        self.s: C = None
        self.r: C = None
        self.txt = txt

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

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

i.y = d
b.z = i
d.q = c
d.r = c
d.y = j
c.z = d
f.t = b
f.p = b
f.z = d
f.s = d
f.r = d
f.v = i
j.s = i
assert f.p.z.y.y.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.t: B = None
        self.z: C = None
        self.v: A = None
        self.p: B = None
        self.s: C = None
        self.r: C = None
        self.txt = txt

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

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

i.y = d
b.z = i
d.q = c
d.r = c
d.y = j
c.z = d
f.t = b
f.p = b
f.z = d
f.s = d
f.r = d
f.v = i
j.s = i
assert f.p.z.y.y.s.y.txt == "d"