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

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

c = A("c")
j = B("j")
i = A("i")
e = A("e")
f = B("f")
h = B("h")
a = B("a")

c.x = e
c.q = i
j.t = c
j.u = c
i.x = c
i.q = c
e.x = c
e.q = i
f.t = e
f.u = c
h.t = e
h.u = c
a.t = i
a.u = e
assert j.u.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.q: A = None
        self.txt = txt

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

c = A("c")
j = B("j")
i = A("i")
e = A("e")
f = B("f")
h = B("h")
a = B("a")

c.x = e
c.q = i
j.t = c
j.u = c
i.x = c
i.q = c
e.x = c
e.q = i
f.t = e
f.u = c
h.t = e
h.u = c
a.t = i
a.u = e
assert j.u.x.x.txt == "c"