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

class B:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.y: A = None
        self.w: B = None
        self.s: F = None
        self.x: E = None
        self.txt = txt

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

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

a = A("a")
c = B("c")
m = C("m")
f = D("f")
j = E("j")
d = F("d")

a.p = m
c.t = f
m.x = a
m.y = a
m.z = c
f.y = a
f.w = c
f.s = d
f.x = j
j.u = m
d.s = f
assert m.z.t.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.y: A = None
        self.w: B = None
        self.s: F = None
        self.x: E = None
        self.txt = txt

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

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

a = A("a")
c = B("c")
m = C("m")
f = D("f")
j = E("j")
d = F("d")

a.p = m
c.t = f
m.x = a
m.y = a
m.z = c
f.y = a
f.w = c
f.s = d
f.x = j
j.u = m
d.s = f
assert m.z.t.w.t.txt == "f"