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

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

b = A("b")
f = B("f")
g = A("g")
e = B("e")
l = A("l")
j = B("j")
k = A("k")
n = B("n")
h = A("h")

b.x = l
b.r = l
f.t = l
f.p = n
g.x = k
g.r = l
e.t = k
e.p = j
l.x = g
l.r = k
j.t = g
j.p = n
k.x = l
k.r = l
n.t = h
n.p = j
h.x = k
h.r = b
assert f.t.x.r.r.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.r: A = None
        self.txt = txt

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

b = A("b")
f = B("f")
g = A("g")
e = B("e")
l = A("l")
j = B("j")
k = A("k")
n = B("n")
h = A("h")

b.x = l
b.r = l
f.t = l
f.p = n
g.x = k
g.r = l
e.t = k
e.p = j
l.x = g
l.r = k
j.t = g
j.p = n
k.x = l
k.r = l
n.t = h
n.p = j
h.x = k
h.r = b
assert f.t.x.r.r.x.x.txt == "g"