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

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

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

d = A("d")
f = B("f")
c = C("c")
g = A("g")
k = B("k")
i = B("i")
j = C("j")
e = B("e")

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

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

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

d = A("d")
f = B("f")
c = C("c")
g = A("g")
k = B("k")
i = B("i")
j = C("j")
e = B("e")

d.p = j
d.u = j
d.r = i
f.y = j
f.o = c
f.x = i
c.q = g
c.u = j
c.o = j
g.p = j
g.u = j
g.r = k
k.y = j
k.o = j
k.x = e
i.y = j
i.o = j
i.x = f
j.q = d
j.u = c
j.o = c
e.y = j
e.o = j
e.x = i
assert j.q.r.x.txt == "f"