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

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

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

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

l = A("l")
g = B("g")
e = C("e")
h = D("h")
j = D("j")

l.y = g
l.q = g
l.x = e
g.t = e
g.v = e
g.w = l
e.q = l
e.x = g
e.w = j
h.v = g
j.v = g
assert g.w.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.q: B = None
        self.x: C = None
        self.txt = txt

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

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

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

l = A("l")
g = B("g")
e = C("e")
h = D("h")
j = D("j")

l.y = g
l.q = g
l.x = e
g.t = e
g.v = e
g.w = l
e.q = l
e.x = g
e.w = j
h.v = g
j.v = g
assert g.w.x.x.txt == "g"