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

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

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

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

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

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

b = A("b")
f = B("f")
h = C("h")
d = D("d")
e = E("e")
l = F("l")
j = E("j")

b.u = j
f.w = e
f.z = h
h.v = b
h.y = j
d.u = j
e.z = j
e.u = l
l.z = h
j.z = e
j.u = l
assert d.u.z.z.u.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: E = None
        self.txt = txt

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

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

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

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

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

b = A("b")
f = B("f")
h = C("h")
d = D("d")
e = E("e")
l = F("l")
j = E("j")

b.u = j
f.w = e
f.z = h
h.v = b
h.y = j
d.u = j
e.z = j
e.u = l
l.z = h
j.z = e
j.u = l
assert d.u.z.z.u.z.txt == "h"