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

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

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

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

l = A("l")
c = B("c")
h = C("h")
a = D("a")
g = D("g")

l.r = c
l.x = c
l.t = h
l.o = a
c.u = l
h.r = a
a.q = h
a.v = h
a.t = g
a.z = l
g.q = h
g.v = h
g.t = a
g.z = l
assert a.t.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.t: C = None
        self.x: B = None
        self.o: D = None
        self.txt = txt

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

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

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

l = A("l")
c = B("c")
h = C("h")
a = D("a")
g = D("g")

l.r = c
l.x = c
l.t = h
l.o = a
c.u = l
h.r = a
a.q = h
a.v = h
a.t = g
a.z = l
g.q = h
g.v = h
g.t = a
g.z = l
assert a.t.t.q.txt == "h"