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

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

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

d = A("d")
h = B("h")
f = C("f")
e = C("e")
c = C("c")
m = B("m")
n = B("n")
a = A("a")

d.r = a
h.s = a
f.y = e
f.r = e
f.t = e
e.y = f
e.r = f
e.t = f
c.y = f
c.r = f
c.t = f
m.s = d
n.s = d
a.r = d
assert e.r.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

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

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

d = A("d")
h = B("h")
f = C("f")
e = C("e")
c = C("c")
m = B("m")
n = B("n")
a = A("a")

d.r = a
h.s = a
f.y = e
f.r = e
f.t = e
e.y = f
e.r = f
e.t = f
c.y = f
c.r = f
c.t = f
m.s = d
n.s = d
a.r = d
assert e.r.y.r.txt == "f"