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

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

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

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

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

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

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

g.w = a
g.x = d
d.u = b
a.z = c
b.t = n
c.x = n
c.z = n
n.u = b
n.y = b
m.w = a
m.x = d
assert n.u.t.u.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.x: B = None
        self.txt = txt

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

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

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

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

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

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

g.w = a
g.x = d
d.u = b
a.z = c
b.t = n
c.x = n
c.z = n
n.u = b
n.y = b
m.w = a
m.x = d
assert n.u.t.u.txt == "b"