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

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

h = A("h")
f = B("f")
c = A("c")
i = A("i")
e = A("e")
d = B("d")

h.t = d
h.v = d
f.r = c
f.p = c
c.t = d
c.v = f
i.t = f
i.v = f
e.t = d
e.v = d
d.r = c
d.p = c
assert d.p.v.p.t.p.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.v: B = None
        self.txt = txt

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

h = A("h")
f = B("f")
c = A("c")
i = A("i")
e = A("e")
d = B("d")

h.t = d
h.v = d
f.r = c
f.p = c
c.t = d
c.v = f
i.t = f
i.v = f
e.t = d
e.v = d
d.r = c
d.p = c
assert d.p.v.p.t.p.v.txt == "f"