class A:
    def __init__(self, txt: str):
        self.y: E = None
        self.z: D = None
        self.t: B = None
        self.p: F = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: A = None
        self.r: F = None
        self.y: A = None
        self.t: D = None
        self.x: C = None
        self.txt = txt

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

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

f.y = h
f.z = m
f.t = n
f.p = c
n.z = c
n.p = h
d.y = m
m.z = h
m.x = n
h.v = f
h.y = f
h.r = c
h.t = m
h.x = d
c.u = n
assert f.y.x.y.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: E = None
        self.z: D = None
        self.t: B = None
        self.p: F = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: A = None
        self.r: F = None
        self.y: A = None
        self.t: D = None
        self.x: C = None
        self.txt = txt

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

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

f.y = h
f.z = m
f.t = n
f.p = c
n.z = c
n.p = h
d.y = m
m.z = h
m.x = n
h.v = f
h.y = f
h.r = c
h.t = m
h.x = d
c.u = n
assert f.y.x.y.x.txt == "n"