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

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

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

g = A("g")
f = B("f")
j = C("j")
b = B("b")
m = A("m")
k = C("k")
i = C("i")
l = A("l")

g.u = b
f.p = b
f.o = i
j.r = k
j.q = k
j.u = i
b.p = f
b.o = j
m.u = b
k.r = j
k.u = j
k.q = j
i.r = j
i.u = j
i.q = k
l.u = b
assert g.u.o.r.q.r.u.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

g = A("g")
f = B("f")
j = C("j")
b = B("b")
m = A("m")
k = C("k")
i = C("i")
l = A("l")

g.u = b
f.p = b
f.o = i
j.r = k
j.q = k
j.u = i
b.p = f
b.o = j
m.u = b
k.r = j
k.u = j
k.q = j
i.r = j
i.u = j
i.q = k
l.u = b
assert g.u.o.r.q.r.u.r.r.txt == "j"