class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.u: C = None
        self.o: A = None
        self.t: D = None
        self.txt = txt

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

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

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

l = A("l")
k = B("k")
j = C("j")
h = D("h")
c = C("c")
e = A("e")
b = B("b")
g = A("g")

l.p = h
l.t = h
l.u = j
l.o = e
k.q = b
k.r = e
j.q = b
j.z = k
j.t = c
j.p = e
h.s = l
h.v = e
h.r = c
c.q = b
c.z = k
c.t = j
c.p = l
e.p = h
e.t = h
e.u = j
e.o = g
b.q = k
b.r = l
g.p = h
g.t = h
g.u = c
g.o = l
assert k.r.o.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.u: C = None
        self.o: A = None
        self.t: D = None
        self.txt = txt

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

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

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

l = A("l")
k = B("k")
j = C("j")
h = D("h")
c = C("c")
e = A("e")
b = B("b")
g = A("g")

l.p = h
l.t = h
l.u = j
l.o = e
k.q = b
k.r = e
j.q = b
j.z = k
j.t = c
j.p = e
h.s = l
h.v = e
h.r = c
c.q = b
c.z = k
c.t = j
c.p = l
e.p = h
e.t = h
e.u = j
e.o = g
b.q = k
b.r = l
g.p = h
g.t = h
g.u = c
g.o = l
assert k.r.o.u.q.txt == "b"