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

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

g = A("g")
h = B("h")
l = A("l")
c = A("c")
f = B("f")
k = B("k")
j = A("j")

g.v = c
g.s = l
h.x = j
l.v = g
l.s = g
c.v = g
c.s = j
f.x = j
k.x = j
j.v = g
j.s = g
assert g.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.s: A = None
        self.txt = txt

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

g = A("g")
h = B("h")
l = A("l")
c = A("c")
f = B("f")
k = B("k")
j = A("j")

g.v = c
g.s = l
h.x = j
l.v = g
l.s = g
c.v = g
c.s = j
f.x = j
k.x = j
j.v = g
j.s = g
assert g.v.v.v.v.txt == "g"