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

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

class C:
    def __init__(self, txt: str):
        self.v: A = None
        self.t: C = None
        self.txt = txt

g = A("g")
n = B("n")
j = C("j")
c = C("c")
a = B("a")
h = A("h")
f = A("f")
i = C("i")

g.r = j
n.u = g
j.v = f
j.t = c
c.v = g
c.t = i
a.u = g
h.r = i
f.r = j
i.v = f
i.t = c
assert g.r.t.v.r.v.r.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.v: A = None
        self.t: C = None
        self.txt = txt

g = A("g")
n = B("n")
j = C("j")
c = C("c")
a = B("a")
h = A("h")
f = A("f")
i = C("i")

g.r = j
n.u = g
j.v = f
j.t = c
c.v = g
c.t = i
a.u = g
h.r = i
f.r = j
i.v = f
i.t = c
assert g.r.t.v.r.v.r.v.txt == "f"