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

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

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

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

g = A("g")
k = B("k")
c = C("c")
d = D("d")
l = D("l")
b = C("b")

g.o = k
g.p = k
g.y = b
k.q = g
k.p = l
k.t = c
k.u = c
c.p = g
c.t = b
d.t = l
d.r = k
l.t = d
l.r = k
b.p = g
b.t = c
assert k.p.r.p.t.r.t.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.p: B = None
        self.y: C = None
        self.txt = txt

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

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

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

g = A("g")
k = B("k")
c = C("c")
d = D("d")
l = D("l")
b = C("b")

g.o = k
g.p = k
g.y = b
k.q = g
k.p = l
k.t = c
k.u = c
c.p = g
c.t = b
d.t = l
d.r = k
l.t = d
l.r = k
b.p = g
b.t = c
assert k.p.r.p.t.r.t.txt == "c"