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

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

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

f = A("f")
e = B("e")
a = C("a")
d = B("d")
c = C("c")
h = C("h")
g = C("g")
j = C("j")

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

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

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

f = A("f")
e = B("e")
a = C("a")
d = B("d")
c = C("c")
h = C("h")
g = C("g")
j = C("j")

f.r = e
f.u = h
f.o = g
e.o = j
e.q = d
e.z = f
a.r = f
a.x = f
a.u = g
d.o = a
d.q = e
d.z = f
c.r = f
c.x = f
c.u = a
h.r = f
h.x = f
h.u = g
g.r = f
g.x = f
g.u = a
j.r = f
j.x = f
j.u = c
assert e.o.u.r.txt == "f"