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

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

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

k = A("k")
n = B("n")
d = C("d")
f = A("f")
l = B("l")
j = B("j")
g = C("g")
e = C("e")

k.u = n
k.y = d
n.r = g
n.o = k
d.p = j
f.u = j
f.y = d
l.r = d
l.o = k
j.r = g
j.o = f
g.p = j
e.p = l
assert k.u.r.p.r.p.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.y: C = None
        self.txt = txt

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

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

k = A("k")
n = B("n")
d = C("d")
f = A("f")
l = B("l")
j = B("j")
g = C("g")
e = C("e")

k.u = n
k.y = d
n.r = g
n.o = k
d.p = j
f.u = j
f.y = d
l.r = d
l.o = k
j.r = g
j.o = f
g.p = j
e.p = l
assert k.u.r.p.r.p.o.y.txt == "d"