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

class B:
    def __init__(self, txt: str):
        self.z: D = None
        self.q: C = None
        self.x: A = None
        self.t: F = None
        self.txt = txt

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

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

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

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

l = A("l")
i = B("i")
g = C("g")
h = D("h")
f = E("f")
d = F("d")

l.u = d
i.z = h
i.q = g
i.x = l
i.t = d
g.y = i
g.v = l
h.y = f
h.x = f
h.p = f
h.t = f
h.r = l
f.z = i
f.s = l
f.p = d
d.r = l
assert h.r.u.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: D = None
        self.q: C = None
        self.x: A = None
        self.t: F = None
        self.txt = txt

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

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

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

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

l = A("l")
i = B("i")
g = C("g")
h = D("h")
f = E("f")
d = F("d")

l.u = d
i.z = h
i.q = g
i.x = l
i.t = d
g.y = i
g.v = l
h.y = f
h.x = f
h.p = f
h.t = f
h.r = l
f.z = i
f.s = l
f.p = d
d.r = l
assert h.r.u.r.u.txt == "d"