class A:
    def __init__(self, txt: str):
        self.v: F = None
        self.x: C = None
        self.r: E = None
        self.y: F = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

b = A("b")
c = B("c")
e = C("e")
j = D("j")
g = E("g")
h = F("h")

b.v = h
b.y = h
b.x = e
b.r = g
c.q = g
c.x = b
e.v = b
e.x = b
j.y = b
g.y = c
h.r = c
assert g.y.q.y.x.r.txt == "
class A:
    def __init__(self, txt: str):
        self.v: F = None
        self.x: C = None
        self.r: E = None
        self.y: F = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

b = A("b")
c = B("c")
e = C("e")
j = D("j")
g = E("g")
h = F("h")

b.v = h
b.y = h
b.x = e
b.r = g
c.q = g
c.x = b
e.v = b
e.x = b
j.y = b
g.y = c
h.r = c
assert g.y.q.y.x.r.txt == "g"