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

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

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

c = A("c")
f = B("f")
i = C("i")
g = A("g")
d = A("d")
n = B("n")
b = C("b")
h = A("h")

c.u = d
c.r = b
c.y = b
f.s = n
i.u = b
g.u = d
g.r = i
g.y = i
d.u = c
d.r = i
d.y = b
n.s = f
b.u = i
h.u = c
h.r = i
h.y = i
assert h.u.u.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.r: C = None
        self.y: C = None
        self.txt = txt

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

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

c = A("c")
f = B("f")
i = C("i")
g = A("g")
d = A("d")
n = B("n")
b = C("b")
h = A("h")

c.u = d
c.r = b
c.y = b
f.s = n
i.u = b
g.u = d
g.r = i
g.y = i
d.u = c
d.r = i
d.y = b
n.s = f
b.u = i
h.u = c
h.r = i
h.y = i
assert h.u.u.r.u.txt == "b"