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

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

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

j = A("j")
g = B("g")
k = C("k")
l = C("l")
h = C("h")
f = A("f")
e = C("e")
b = B("b")

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

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

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

j = A("j")
g = B("g")
k = C("k")
l = C("l")
h = C("h")
f = A("f")
e = C("e")
b = B("b")

j.r = b
j.o = h
g.s = f
g.y = b
g.x = b
k.r = f
k.s = f
k.p = b
l.r = f
l.p = b
l.s = j
h.r = j
h.s = j
h.p = b
f.r = b
f.o = h
e.r = f
e.s = f
e.p = b
b.s = f
b.y = g
b.x = g
assert e.s.r.x.s.txt == "f"