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

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

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

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

l = A("l")
k = B("k")
a = C("a")
e = D("e")
h = C("h")
m = B("m")

l.v = m
k.x = l
k.r = e
k.w = e
k.p = h
a.t = h
e.q = l
e.u = h
e.y = k
h.t = a
m.x = l
m.r = e
m.w = e
m.p = a
assert h.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

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

l = A("l")
k = B("k")
a = C("a")
e = D("e")
h = C("h")
m = B("m")

l.v = m
k.x = l
k.r = e
k.w = e
k.p = h
a.t = h
e.q = l
e.u = h
e.y = k
h.t = a
m.x = l
m.r = e
m.w = e
m.p = a
assert h.t.t.t.t.t.txt == "a"