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

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

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

l = A("l")
c = B("c")
f = C("f")
b = A("b")
a = C("a")
h = B("h")
d = B("d")
j = A("j")
i = A("i")

l.u = a
c.r = a
f.w = i
f.o = i
b.u = f
a.w = i
a.o = j
h.r = f
d.r = a
j.u = a
i.u = f
assert j.u.o.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

l = A("l")
c = B("c")
f = C("f")
b = A("b")
a = C("a")
h = B("h")
d = B("d")
j = A("j")
i = A("i")

l.u = a
c.r = a
f.w = i
f.o = i
b.u = f
a.w = i
a.o = j
h.r = f
d.r = a
j.u = a
i.u = f
assert j.u.o.u.txt == "a"