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

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

g = A("g")
j = B("j")
i = A("i")
l = B("l")
n = B("n")
f = A("f")

g.p = n
g.v = n
j.t = n
j.o = n
i.p = l
i.v = n
l.t = n
l.o = j
n.t = l
n.o = j
f.p = j
f.v = j
assert j.t.o.o.t.t.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.v: B = None
        self.txt = txt

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

g = A("g")
j = B("j")
i = A("i")
l = B("l")
n = B("n")
f = A("f")

g.p = n
g.v = n
j.t = n
j.o = n
i.p = l
i.v = n
l.t = n
l.o = j
n.t = l
n.o = j
f.p = j
f.v = j
assert j.t.o.o.t.t.o.txt == "j"