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

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

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

b.s = i
b.r = l
l.t = b
d.s = i
d.r = i
e.s = l
e.r = l
h.s = i
h.r = i
n.s = l
n.r = l
g.s = l
g.r = i
f.s = l
f.r = l
i.t = d
c.s = i
c.r = i
assert e.r.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.r: B = None
        self.txt = txt

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

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

b.s = i
b.r = l
l.t = b
d.s = i
d.r = i
e.s = l
e.r = l
h.s = i
h.r = i
n.s = l
n.r = l
g.s = l
g.r = i
f.s = l
f.r = l
i.t = d
c.s = i
c.r = i
assert e.r.t.s.txt == "i"